<CFIF ISDEFINED("FORM.btnBackHome")>
	<CFLOCATION url="#client.domain#eworksched/">
</CFIF>
<CFMODULE TEMPLATE="#client.common_path#cfm_DBdateFormat.cfm">
<CFSET sDateNow = dateResult>
<CFSET webCompCode = "worksched">
<CFSET session.tabId = "worksched">

<CFSET sID = Decrypt(url.id,client.ek)>
<CFSET sIDUrlEnc = URLEncodedFormat(Encrypt(sID,client.ek))>
<CFSET wsIDnum = "">
<CFSET wsIDnumEnc = "">
<CFSET vPosted ="">
<CFSET wsAction = "">
<CFSET wsActionEnc ="">
<CFSET appno="">
<CFSET appnoENC="">
<CFPARAM NAME="sWarn" default="">
<CFPARAM NAME="sMess" DEFAULT="">
<CFIF isDefined("url.posted")>
	<CFSET vPosted = Decrypt(url.posted,client.ek)>
	<CFSET url.posted = URLEncodedFormat(encrypt(vPosted,client.ek))>
</CFIF>
<CFIF isDefined("url.appno") AND url.appno NEQ "">
	<CFSET appno = Decrypt(url.appno,client.ek)>
	<CFSET encappno = URLEncodedFormat(encrypt(appno,client.ek))>
</CFIF>
<CFIF ISDEFINED("FORM.EDTDOCNUMBER")>
	<CFSET wsIDnum = FORM.EDTDOCNUMBER>
	<CFSET wsIDnumEnc = URLEncodedFormat(encrypt(wsIDnum,client.ek))>
	<CFSET url.wsnum = wsIDnumEnc>
<CFELSEIF isDefined("url.wsnum") AND url.wsnum NEQ "">
	<CFSET wsIDnum = decrypt(url.wsnum,client.ek)>
	<CFSET wsIDnumEnc = URLEncodedFormat(encrypt(wsIDnum,client.ek))>
</CFIF>

<CFIF isDefined("url.myaction") and url.myaction neq "">
	<CFSET wsAction = decrypt(url.myaction,client.ek)>
	<CFSET wsActionEnc = URLEncodedFormat(encrypt(wsAction,client.ek))>
	<CFSET url.myaction = wsActionEnc>
</CFIF>

<CFSET allURL="">
<CFLOOP LIST="currfolder" index="theURL">
	<CFMODULE TEMPLATE="#client.common_path#cfm_geturlvariables.cfm" INCLUDEURL="#theURL#">
	<CFIF urlVariables NEQ "">
		<CFSET allURL = allURL & "&" & urlVariables>
	</CFIF>
</CFLOOP>
<CFMODULE TEMPLATE = "#client.common_path#cfm_checkuserrecords.cfm" USERTABLE = "ECRTWORKSCHED"
	USERFIELD = "USERGRPID_FK" RECORDFIELD = "WSCODE_FK" RECORDID = "#sId#" BOOLEANFIELDS = "ISADD,ISDELETE,ISEDIT,ISVIEW,ISCOPY">
<CFQUERY NAME="getECRG" DATASOURCE="#client.company_dsn#">
	SELECT * FROM ECRGWORKSCHED
	WHERE WSCODE = '#sID#'
</CFQUERY>
<CFQUERY NAME="QueryView" DATASOURCE="#client.company_dsn#">
	SELECT * FROM CINWORKSCHED
	WHERE WSCODE_FK = '#sID#'
	<CFIF getECRG.ISSHARED NEQ "Y">
		AND RECCREATEDBY ='#client.userid#'
	</CFIF>
	<CFIF ISDEFINED("FORM.FILTER") AND NOT ISDEFINED("FORM.hidemployee") AND NOT ISDEFINED("FORM.hidviewrec")>
		AND #FORM.CMBSORT# LIKE '%#FORM.EDTVALFILTER#%'
		ORDER BY #FORM.CMBSORT# #FORM.ASCDESC#
	<CFELSE>
		ORDER BY WSNUMBER DESC, DESCRIPTION
	</CFIF>
</CFQUERY>
<CFSET sFilterEmployee=False>
<CFIF ISDEFINED("FORM.FILTER") AND ISDEFINED("FORM.hidemployee")>
	<CFSET sFilterEmployee=true>
</cfif>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<TITLE>iBOS/e eWorkSked</TITLE>
	<CFOUTPUT>
	<LINK REL="StyleSheet" HREF="#client.wstheme_path##client.empcolor#.css" TYPE="text/css">
	</CFOUTPUT>
</HEAD>
<CFSET isCommand="">
<BODY LEFTMARGIN=0 RIGHTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0>

		<CFINCLUDE TEMPLATE="#client.common_path#_toggle.cfm">
		<CFMODULE TEMPLATE="#client.common_path#cfm_workspace.cfm" MODULE="#webCompCode#" COMPONENT="#getECRG.wsDESCRIPTION#" LOCATION="../">
		<TABLE BORDER="0" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
			<TR>
				<TD>
					<CFIF ISDEFINED("url.recordview")>
						<CFIF ISDEFINED("FORM.BTNSELEMP")>
							<CFIF FORM.edtDateFrom EQ "" OR FORM.edtDateTo EQ "">
								<script>
									alert("Fill up the Date Range first.");
								</script>
							<CFELSE>
                            	<CFSET CLIENT.edtDateFrom=FORM.edtDateFrom>
								<CFSET CLIENT.edtDateTo=FORM.edtDateTo>
								<CFINCLUDE TEMPLATE="../common/selempview.cfm">
							</CFIF>
						<CFELSEIF ISDEFINED("FORM.btnProceed")>
							<CFIF FORM.edtDateFrom EQ "" OR FORM.edtDateTo EQ "">
								<script>
									alert("Fill up the Date Range first.");
								</script>
							<CFELSE>
								<CFSET CLIENT.edtDateFrom=FORM.edtDateFrom>
								<CFSET CLIENT.edtDateTo=FORM.edtDateTo>
							</CFIF>
							<CFINCLUDE TEMPLATE="viewrec.cfm">
						<CFELSEIF ISDEFINED("FORM.filter")>
							<CFINCLUDE TEMPLATE="../common/selempview.cfm">
						<CFELSE>
							<CFINCLUDE TEMPLATE="viewrec.cfm">
						</CFIF>
					
					<CFELSEIF ISDEFINED("form.btnSavePerm")>
						<CFSET isCommand="saveperm">
						<CFINCLUDE TEMPLATE="../common/savedata.cfm">
						<CFINCLUDE TEMPLATE="details.cfm">
					<CFELSEIF isDefined("form.BTNBACKACTION")>
						<CFINCLUDE TEMPLATE="list.cfm">
					<CFELSEIF ISDEFINED("form.btnPost")>
						<CFSET isCommand="savedata">
						<CFQUERY NAME="GetEntry" DATASOURCE="#client.company_dsn#">
							SELECT * FROM CINWORKSCHED
							WHERE WSCODE_FK = '#sID#'
								AND WSNUMBER='#wsIDnum#'
						</CFQUERY>
						<CFQUERY NAME="GetDTLmaster" DATASOURCE="#client.company_dsn#">
							SELECT * FROM CINWSMASTERPOOL
							WHERE WSNUMBER_FK='#wsIDnum#'
						</CFQUERY>
						<CFQUERY NAME="GetDTLsubtemp" DATASOURCE="#client.company_dsn#">
							SELECT * FROM CINWSSUBSKEDPOOL
							WHERE WSNUMBER_FK='#wsIDnum#'
								AND (PATTERNCODE IS NOT NULL AND PATTERNCODE != '')
						</CFQUERY>
						<CFQUERY NAME="GetDTLtemp" DATASOURCE="#client.company_dsn#">
							SELECT * FROM CINWSTEMPSKEDPOOL
							WHERE WSNUMBER_FK='#wsIDnum#'
						</CFQUERY>
						<CFIF GetDTLmaster.RECORDCOUNT OR GetDTLtemp.RECORDCOUNT OR GetDTLsubtemp.RECORDCOUNT>
							<CFINCLUDE TEMPLATE="../common/savedata.cfm">
							<CFINCLUDE TEMPLATE="../../eforms/post_activities/postworksked.cfm">
							<CFINCLUDE TEMPLATE="list.cfm">
						<CFELSE>
							<CFSET sIDUrlEnc = URLEncodedFormat(Encrypt(sID,client.ek))>
							<CFSET idDetVal = URLEncodedFormat(Encrypt(wsIDnum,client.ek))>
							<CFSET actEdit=urlEncodedFormat(encrypt("edit", client.ek))>
							<CFSET actPosted = URLEncodedFormat(encrypt("No",client.ek))>
							
							<CFLOCATION url="#client.domain#eworksched/wsmain/index.cfm?id=#sIDUrlEnc#&wsnum=#idDetVal#&myAction=#actEdit#&posted=#actPosted#&notroute=">
						</CFIF>
					<CFELSEIF ISDEFINED("form.btnRoute")>
						<CFSET isCommand="savedata">
						<CFSET theFormCode=getECRG.FORMCODE>
						<CFSET theCode=getECRG.WSCODE>
						<CFINCLUDE TEMPLATE="../common/savedata.cfm">
						<CFINCLUDE TEMPLATE="../common/_route.cfm">
						<CFINCLUDE TEMPLATE="list.cfm">
					<CFELSEIF ISDEFINED("form.btnSaveTemp")>
						<CFSET isCommand="savetemp">
						<CFINCLUDE TEMPLATE="../common/savedata.cfm">
						<CFINCLUDE TEMPLATE="details.cfm">
					<CFELSEIF ISDEFINED("form.btnSaveSub")>
						<CFSET isCommand="savesub">
						<CFINCLUDE TEMPLATE="../common/savedata.cfm">
						<CFINCLUDE TEMPLATE="details.cfm">
					<CFELSEIF ISDEFINED("form.BTNDELETEPERM")>
						<CFSET isCommand="delperm">
						<CFINCLUDE TEMPLATE="../common/savedata.cfm">
						<CFINCLUDE TEMPLATE="details.cfm">
					<CFELSEIF ISDEFINED("form.btnDeleteSub")>
						<CFSET isCommand="delsub">
						<CFINCLUDE TEMPLATE="../common/savedata.cfm">
						<CFINCLUDE TEMPLATE="details.cfm">
					<CFELSEIF ISDEFINED("form.btnDeleteTemp")>
						<CFSET isCommand="deltemp">
						<CFINCLUDE TEMPLATE="../common/savedata.cfm">
						<CFINCLUDE TEMPLATE="details.cfm">
					<CFELSEIF ISDEFINED("form.btnDeleteEmployee")>
						<CFSET isCommand="deleteemp">
						<CFINCLUDE TEMPLATE="../common/savedata.cfm">
						<CFINCLUDE TEMPLATE="details.cfm">
					<CFELSEIF ISDEFINED("form.btnResetAction")>
						<CFSET isCommand="resetrecord">
						<CFINCLUDE TEMPLATE="../common/savedata.cfm">
						<CFINCLUDE TEMPLATE="details.cfm">
					<CFELSEIF ISDEFINED("form.btnApplyChanges")>
						<CFSET isCommand="updatechanges">
						<CFINCLUDE TEMPLATE="../common/savedata.cfm">
						<CFINCLUDE TEMPLATE="details.cfm">
					<!--- button was removed
					<CFELSEIF ISDEFINED("form.btnSaveDates")>
						<CFSET isCommand="savedate">
						<CFINCLUDE TEMPLATE="../common/savedata.cfm">
						<CFINCLUDE TEMPLATE="details.cfm">
						
					--->
					<CFELSEIF isDefined("form.btnAddEmployee") OR isDefined("form.BTNSAVEACTION") OR sFilterEmployee OR isDefined("Form.First") OR isDefined("Form.Prior") OR isDefined("Form.Next") OR isDefined("Form.Last")>
						<CFIF sFilterEmployee OR isDefined("Form.First") OR isDefined("Form.Prior") OR isDefined("Form.Next") OR isDefined("Form.Last")>
							<CFINCLUDE TEMPLATE="../common/addemp.cfm">
						<CFELSEIF form.edtDESCRIPTION EQ "" OR form.edtDateFrom EQ "" OR form.edtDateTo EQ "">
							<CFSET sWarn="Fill up the required fields.">
							<CFINCLUDE TEMPLATE="details.cfm">
						<CFELSE>
							<CFSET isCommand="savedata">
							<CFINCLUDE TEMPLATE="../common/savedata.cfm">
							<CFIF ISDEFINED("form.BTNSAVEACTION")>
								<CFINCLUDE TEMPLATE="list.cfm">
							<CFELSE>
								<CFINCLUDE TEMPLATE="../common/addemp.cfm">
							</CFIF>
						</CFIF>
					<CFELSEIF wsAction EQ "delete">
						<CFSET isCommand="deletefile">
						<CFINCLUDE TEMPLATE="../common/savedata.cfm">
						<CFINCLUDE TEMPLATE="list.cfm">
					<CFELSEIF isDefined("form.btnAddEmp")>
						<CFSET isCommand="AddEmp">
						<CFINCLUDE TEMPLATE="../common/savedata.cfm">
						<CFINCLUDE TEMPLATE="details.cfm">
					<CFELSEIF wsAction EQ "edit" OR wsAction EQ "copy" OR ISDEFINED("FORM.BTNBACKADD") OR ISDEFINED("form.btnISADD") OR isdefined("url.appno") OR ISDEFINED("URL.CURRFOLDER")>
						<CFINCLUDE TEMPLATE="details.cfm">
					<CFELSE>
						<CFINCLUDE TEMPLATE="list.cfm">
					</CFIF>
				</TD>
			</TR>
		</TABLE>
		<CFMODULE TEMPLATE="#client.common_path#cfm_workspace.cfm" TOP="False">
</BODY>

